﻿package cn.poco.pepsi.util.xmlpared;

import java.io.InputStream;

import org.xmlpull.v1.XmlPullParser;

import android.util.Xml;
import cn.poco.pepsi.bean.City;


public class GPSCityXmlparse {
	//private final static String TAG = "GPSCityXmlparse";
	private static  City cityBean = null;
	
	public static City getXml(InputStream inSteam) throws Exception{
		XmlPullParser xmpparse = Xml.newPullParser();   //得到解释器
		xmpparse.setInput(inSteam, "UTF-8");           //设置解释流
		int code = xmpparse.getEventType();            //得到节点信息
		while(code!=XmlPullParser.END_DOCUMENT){
			switch (code) {
			case XmlPullParser.START_TAG:
				if("city".equals(xmpparse.getName())){
					cityBean = new City();
				}
				if(cityBean!=null){
					if("key".equals(xmpparse.getName())){
						String key = xmpparse.nextText();
						cityBean.setKey(key);
					}
					if("address".equals(xmpparse.getName())){
						String name = xmpparse.nextText();
						cityBean.setName(name);
					}
				}
				break;
			}	
			code = xmpparse.next();
		}
		inSteam.close();
		return cityBean;
	}
}
